Halogen Componentのcomponent
from Halogen Component
諸々のパーツを組み合わせてHalogen Componentを作成する
例
code:purs(hs)
component :: forall query input output m. H.Component query input output m
component =
H.mkComponent
{ initialState
, render
, eval: H.mkEval $ H.defaultEval { handleAction = handleAction }
}
component関数
componentそのもの
型についてはH.Component型を参照
H.mkComponentを使って基本的な構造を作る
H.mkComponent
3つのfieldを持つ
initialState
render
eval
これらのfieldをまとめてComponentSpecと呼ぶ
型
code:purs(hs)
type ComponentSpec state query action slots input output m =
{ initialState :: input -> state
, render :: state -> HC.HTML (ComponentSlot slots m action) action
, eval :: HalogenQ query action input ~> HalogenM state action slots output m
}
2021/9/2 Halogenの型だけ見て概念の俯瞰をする#61304fd019827000006d1b80
eval
5つのfieldを持つ
handleAction
receve
handleQuery
initialize
finalize
code:purs(hs)
type EvalSpec state query action slots input output m =
{ handleAction :: action -> HalogenM state action slots output m Unit
, handleQuery :: forall a. query a -> HalogenM state action slots output m (Maybe a)
, receive :: input -> Maybe action
, initialize :: Maybe action
, finalize :: Maybe action
}
それぞれ何を表す #??
2021/9/2 Halogenの型だけ見て概念の俯瞰をする#61305a4a19827000006d1bc6